package VIEW;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import DAL.BaseDAO;
import DAL.BaseItemDAO;
import DAL.DoAsapItemDAO;
import DOMAIN.BaseItem;
import DOMAIN.DoAsapItem;

public class ListDoAsapItemServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
	throws IOException, ServletException{
	
		BaseDAO<DoAsapItem> dao = new DoAsapItemDAO();
		request.setAttribute("DoAsapItems", dao.GetList());
	request.getRequestDispatcher("ListDoAsapItem.jsp").forward(request, response);	
	}	
	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
	throws IOException, ServletException{
		
		BaseDAO<BaseItem> dao = new BaseItemDAO();
		DoAsapItem item = new DoAsapItem();
		item.SetTitle(request.getParameter("titre"));
		item.SetDescription(request.getParameter("description"));
		item.SetActionnable(false);
		item.SetActive(false);
		item.SetDone(false);
		if(dao.Create(item))
		{
		BaseDAO<DoAsapItem> daoti = new DoAsapItemDAO();
		daoti.Create(item);
		}
		doGet(request,response);
	}


}